package com.oulu.ruokkis.model;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

public class Restaurant {
	private String name;
	private String date;
	private String dayOfWeek;
	private List<Dish> dishes;	
	private final String[] days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	
	public Restaurant() {

	}

	public Restaurant(String name)
	{
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public List<Dish> getArrayChildren() {
		return dishes;
	}

	public void setArrayChildren(List<Dish> mArrayChildren) {
		this.dishes = mArrayChildren;
	}
	
	public void add(Dish dish)
	{
		if(dishes == null)
		{
			dishes = new ArrayList<Dish>();
			dishes.add(dish);
		}
		else
			dishes.add(dish);
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return name;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date.trim();
		String[] temp = date.split("\\.");
				
		// TODO improve this function
		
		SimpleDateFormat format1 = new SimpleDateFormat("dd.MM.yyyy");
		Date dt1;
		try {
			dt1 = format1.parse(date);
			DateFormat format2 = new SimpleDateFormat("EEEE");
			dayOfWeek = format2.format(dt1);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	public String getDayOfWeek() {
		return dayOfWeek;
	}

}